package VISTA;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class frmListados extends javax.swing.JFrame {
	private JPanel pnlListados;
	private JPanel pnlListadoIngredientes;
	private JPanel pnlOrden;
	private JScrollPane scpProductoOrdenes;
	private JTable tblProductoOrdenes;
	private JRadioButton rbtnDescendente;
	private ButtonGroup buttonGroup3;
	private ButtonGroup buttonGroup2;
	private ButtonGroup buttonGroup1;
	private JButton btnCancelar;
	private JButton btnCargarListados;
	private JRadioButton rbtnMas;
	private JRadioButton rbtnAscendente;
	private JRadioButton rbtnProductos;
	private JRadioButton rbtnIngredientes;
	private JPanel pnlFiltro;
	private JPanel pnlListadoVentas;
	private DefaultTableModel modeloIngrediente,modeloProducto,modeloMas;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				frmListados inst = new frmListados();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public frmListados() {
		super("Listados");
		initGUI();
		modeloIngrediente= new DefaultTableModel(null,
				new String[] { "Ingrediente", "Stock en Almacen" });

		modeloProducto= new DefaultTableModel(null,
				new String[] { "Producto", "Total Generado","Cantidad Vendida" });
		modeloMas= new DefaultTableModel(null,
				new String[] { "Ingrediente", "Cantidade Usada" });
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				pnlListados = new JPanel();
				getContentPane().add(pnlListados, BorderLayout.CENTER);
				pnlListados.setLayout(null);
				pnlListados.setBackground(new java.awt.Color(255,255,255));
				pnlListados.setPreferredSize(new java.awt.Dimension(774, 467));
				{
					
					pnlListadoVentas = new JPanel();
					pnlListadoVentas.setBorder(BorderFactory.createTitledBorder("Listados"));
					pnlListados.add(pnlListadoVentas);
					pnlListadoVentas.setLayout(null);
					pnlListadoVentas.setBounds(29, 12, 728, 211);
					pnlListadoVentas.setBackground(new java.awt.Color(228,196,116));
					{
						
						pnlFiltro = new JPanel();
						pnlFiltro.setBorder(BorderFactory.createTitledBorder("Selecione"));
						pnlListadoVentas.add(pnlFiltro);
						pnlFiltro.setLayout(null);
						pnlFiltro.setBounds(89, 32, 329, 152);
						pnlFiltro.setBackground(new java.awt.Color(255,255,255));
						{
							rbtnIngredientes = new JRadioButton();
							pnlFiltro.add(rbtnIngredientes);
							rbtnIngredientes.setText("Listado de Ingredientes");
							rbtnIngredientes.setBounds(35, 30, 272, 30);
							rbtnIngredientes.setBackground(new java.awt.Color(255,255,255));
							rbtnIngredientes.setActionCommand("Ingredientes");
							getButtonGroup1().add(rbtnIngredientes);
						}
						{
							rbtnProductos = new JRadioButton();
							pnlFiltro.add(rbtnProductos);
							rbtnProductos.setText("Listado de Productos Vendidos");
							rbtnProductos.setBounds(35, 67, 278, 30);
							rbtnProductos.setBackground(new java.awt.Color(255,255,255));
							rbtnProductos.setActionCommand("Productos");
							getButtonGroup1().add(rbtnProductos);
						}
						{
							rbtnMas = new JRadioButton();
							pnlFiltro.add(rbtnMas);
							rbtnMas.setText("Listado de Ingredientes mas Usados");
							rbtnMas.setBounds(35, 104, 278, 30);
							rbtnMas.setBackground(new java.awt.Color(255,255,255));
							rbtnMas.setActionCommand("Mas");
							getButtonGroup1().add(rbtnMas);
						}
					}
					{
						
						pnlOrden = new JPanel();
						pnlOrden.setBorder(BorderFactory.createTitledBorder("Orden"));
						pnlListadoVentas.add(pnlOrden);
						pnlOrden.setLayout(null);
						pnlOrden.setBounds(438, 36, 285, 148);
						pnlOrden.setBackground(new java.awt.Color(255,255,255));
						{
							rbtnAscendente = new JRadioButton();
							pnlOrden.add(rbtnAscendente);
							rbtnAscendente.setText("Ascendente");
							rbtnAscendente.setBounds(64, 34, 171, 30);
							rbtnAscendente.setBackground(new java.awt.Color(255,255,255));
							rbtnAscendente.setActionCommand("Asc");
							getButtonGroup2().add(rbtnAscendente);
						}
						{
							rbtnDescendente = new JRadioButton();
							pnlOrden.add(rbtnDescendente);
							rbtnDescendente.setText("Descendente");
							rbtnDescendente.setBounds(64, 71, 171, 30);
							rbtnDescendente.setBackground(new java.awt.Color(255,255,255));
							rbtnDescendente.setActionCommand("Asc");
							getButtonGroup2().add(rbtnDescendente);
						}
					}
				}
				{
					
					pnlListadoIngredientes = new JPanel();
					pnlListadoIngredientes.setBorder(BorderFactory.createTitledBorder("Listado"));
					pnlListados.add(pnlListadoIngredientes);
					pnlListadoIngredientes.setLayout(null);
					pnlListadoIngredientes.setBounds(29, 259, 728, 184);
					pnlListadoIngredientes.setBackground(new java.awt.Color(228,196,116));
					pnlListadoIngredientes.add(getScpProductoOrdenes());
				}
				{
					btnCargarListados = new JButton();
					pnlListados.add(btnCargarListados);
					btnCargarListados.setText("Generar");
					btnCargarListados.setBounds(272, 455, 107, 34);
					btnCargarListados.setActionCommand("Generar");
				}
				{
					btnCancelar = new JButton();
					pnlListados.add(btnCancelar);
					btnCancelar.setText("Cancelar");
					btnCancelar.setBounds(410, 455, 107, 34);
					btnCancelar.setActionCommand("Cancelar");
				}
			}
			pack();
			this.setSize(784, 530);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	
	
	private JScrollPane getScpProductoOrdenes() {
		if(scpProductoOrdenes == null) {
			scpProductoOrdenes = new JScrollPane();
			scpProductoOrdenes.setBounds(17, 20, 694, 147);
			scpProductoOrdenes.setViewportView(getTblProductoOrdenes());
		}
		return scpProductoOrdenes;
	}
	
	private JTable getTblProductoOrdenes() {
		if(tblProductoOrdenes == null) {
			tblProductoOrdenes = new JTable();
		//	tblProductoOrdenes.setModel(tblProductoOrdenesModel);
			tblProductoOrdenes.setPreferredSize(new java.awt.Dimension(489,144));
		}
		return tblProductoOrdenes;
	}
	
	public void addListener(ActionListener actionListener){
		this.btnCancelar.addActionListener(actionListener);
		this.btnCargarListados.addActionListener(actionListener);
		this.rbtnAscendente.addActionListener(actionListener);
		this.rbtnDescendente.addActionListener(actionListener);
		this.rbtnIngredientes.addActionListener(actionListener);
		this.rbtnMas.addActionListener(actionListener);
		this.rbtnProductos.addActionListener(actionListener);
	}

	public DefaultTableModel getModeloIngrediente() {
		return modeloIngrediente;
	}

	public void setModeloIngrediente(DefaultTableModel modeloIngrediente) {
		this.modeloIngrediente = modeloIngrediente;
	}

	public DefaultTableModel getModeloProducto() {
		return modeloProducto;
	}

	public void setModeloProducto(DefaultTableModel modeloProducto) {
		this.modeloProducto = modeloProducto;
	}

	public DefaultTableModel getModeloMas() {
		return modeloMas;
	}

	public void setModeloMas(DefaultTableModel modeloMas) {
		this.modeloMas = modeloMas;
	}

	public void setTblProductoOrdenes(JTable tblProductoOrdenes) {
		this.tblProductoOrdenes = tblProductoOrdenes;
	}
	
	public JTable getProductoOrdenes() {
		return tblProductoOrdenes;
	}
	
	public void mostrarMensaje(String mensaje) {
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	private ButtonGroup getButtonGroup1() {
		if(buttonGroup1 == null) {
			buttonGroup1 = new ButtonGroup();
		}
		return buttonGroup1;
	}
	
	private ButtonGroup getButtonGroup2() {
		if(buttonGroup2 == null) {
			buttonGroup2 = new ButtonGroup();
		}
		return buttonGroup2;
	}

}
